import path from "path";
export default (number:number=1,bool=true)=>{
    // @ts-ignore
    Error.prepareStackTrace = function(_, stack){ return stack; };
    const err = new Error;
    let stack:any = err.stack;
    stack = stack.filter((e)=>!/node:internal|internal/.test(e.getFileName()));
    //bool为真返回完整的文件路径
    if(bool){
        return stack[number].getFileName();
    }else{
        //返回父路径
        let sup = path.dirname(stack[number].getFileName());
        if(sup.startsWith("file:"))sup=sup.substring(8)
        return sup;
    }
}